<template>
  <div :class="$style.container">
    <BaseInfo/>
    <OrderList/>
    <FilmList :lists="lists"/>
    <Footor/>
    <div>
      <loading :show="showLoading" text="加载中..."></loading>
      <alert v-model="showAlert" title="提示" :content="tip"></alert>
    </div>
  </div> 
</template>
<script>
import { Loading, Alert } from 'vux'
import BaseInfo from './components/userInfo'
import OrderList from './components/orderList'
import FilmList from './components/filmList'
import Footor from './components/footor'
import http from '../../APIService/http'
export default {
  data () {
    return {
      showLoading: false,
      showAlert: false,
      tip: '',
      lists: []
    }
  },
  components: {
    BaseInfo,
    OrderList,
    FilmList,
    Footor,
    Loading,
    Alert
  },
  mounted () {
    this.init()
  },
  methods: {
    async init () {
      try {
        if (!this.$Cookie.getToken()) {
          this.$router.push({
            path: '/login'
          })
          return false
        }
        this.showLoading = true
        let res = await http.get(`/dianshang/getLike`)
        if (res.code === 0) {
          this.showLoading = false
          this.lists = res.data
        } else if (res.code === -1) {
          this.showLoading = false
          this.tip = res.msg
          this.showAlert = true
        } else {
          throw new Error('error')
        }
      } catch (err) {
        console.log('get film list fail')
        this.showLoading = false
      }
    }
  }
}
</script> 
<style lang="less" module>
.container {
   min-height: 100vh;
   background: #f4f4f4;
   .desc {
     color:#999;
     padding: 20px;
     font-size:14px;
   }
}
</style>